package com.shd.edanpei.ui.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseQuickImageAdapter;
import com.shd.edanpei.bean.OrderListModel;

/**
 * Created by mc on 2018/10/17.
 * yang-wen-wen
 */

public class HomeAdapter extends BaseQuickImageAdapter<OrderListModel> {

    public HomeAdapter(Context context) {
        super(context, R.layout.item_home);
    }

    @Override
    protected void convert(BaseViewHolder helper, OrderListModel item) {
        helper.setText(R.id.tv_money,item.getAmount())
                .setText(R.id.tv_area,item.getArea().replace(" ",""))
                .setText(R.id.tv_name,item.getCreateUserName(item))
                .addOnClickListener(R.id.tv_take);

        //是否被接单
        if (item.getUserStatus() == 2) {
            //未被接单
            helper.getView(R.id.tv_take).setBackground(ContextCompat.getDrawable(mContext, R.drawable.shape_main_button));
            helper.setText(R.id.tv_take, "我要接单");
        } else {
            //已经被接单
            helper.getView(R.id.tv_take).setBackground(ContextCompat.getDrawable(mContext, R.drawable.shape_rad6dp_gray));
            helper.setText(R.id.tv_take, "已被接单");
        }
    }

}
